package com.kevin.learn;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class CountTest {
    public static void main(String[] args) {

        BigDecimal amount = new BigDecimal("111860");
        BigDecimal earnings = new BigDecimal("0");

        BigDecimal monthAmount = amount.divide(new BigDecimal("60"), 2, RoundingMode.UP);// 免息计算
        monthAmount = new BigDecimal("2174");// 固定
        System.out.println("每期金额:" + monthAmount.toString());

        while (amount.compareTo(new BigDecimal("0")) == 1) {

            earnings = earnings.add(amount.multiply(new BigDecimal("0.04")).divide(new BigDecimal("12"), 2, RoundingMode.UP));
            System.out.println("收益:" + earnings.toString());
            amount = amount.subtract(monthAmount);
            System.out.println("本金:" + amount.toString());
            System.out.println("--------------------");
            amount.toString();
        }
    }
}
